package com.lois.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lois.listener.UploadDataListener;
import com.lois.listener.UploadDataListener2;
import com.lois.mapper.UploadMapper;
import com.lois.mapper.UploadMapper2;
import com.lois.model.UploadData;
import com.lois.model.UploadData2;
import com.lois.service.UploadService;
import com.lois.utils.UploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.InputStream;
import java.util.List;

/**
 * 有个很重要的点 DemoDataListener 不能被spring管理，要每次读取excel都要new,然后里面用到spring可以构造方法传进去
 *
 * @author lois
 * @since 2020-03-02
 */
@Service
public class UploadServiceImpl extends ServiceImpl<UploadMapper, UploadData> implements UploadService {

    @Autowired
    private UploadMapper uploadMapper;

    @Autowired
    private UploadMapper2 uploadMapper2;

    @Override
    public void upload(InputStream file) {
        UploadUtils.test1(file, UploadData.class, new UploadDataListener(uploadMapper));
    }

    @Override
    public void upload2(InputStream file) {
        UploadUtils.test1(file, UploadData2.class, new UploadDataListener2(uploadMapper2));
    }

    @Override
    public List<UploadData> findList() {
        return uploadMapper.findList();
    }
}
